<template>
	<view>
		<view class="couponList">
			<view class="couponItem" v-for="(item,index) in couponList" :key="index">
				<image src="../../static/img/active/coupon.png" class="itemBg" mode=""></image>
				<view class="itemInfo">
					<view class="value" v-if="item.value!='0.0'">{{item.value*10}}折</view>
					<view class="value" v-else>免单</view>
					<view class="infoOther">
						<view class="title">{{item.title}}</view>
						<view class="time">有效期：{{item.endtime}}</view>
					</view>
					<image src="../../static/img/active/use.png" class="use" mode="" @click="navigatorPage"></image>
				</view>
			</view>
		</view>
		<view class="noData" v-if="couponList.length==0">
			<image src="../../static/img/common/nodata.png" class="image"></image>
			<view class="text">还没有获得优惠券哦～</view>
		</view>
	</view>
</template>

<script>
	import {
		getCouponList
	} from "@/api/active.js"
	export default {
		data() {
			return {
				venues_id: null,
				couponList: []
			}
		},
		onLoad(options) {
			if (options && options.venues_id) {
				this.venues_id = options.venues_id
			}
		},
		onShow() {
			this.getCouponList()
		},
		methods: {
			navigatorPage(){
				uni.switchTab({
					url:"/pages/index/index"
				})
			},
			getCouponList() {
				getCouponList({
					venues_id: this.venues_id
				}).then(res => {
					this.couponList = res.data
				})
			}
		}
	}
</script>

<style lang="scss" scoped>
	.noData {
		padding-top: 390rpx;
		margin: 0 auto;
		text-align: center;

		.image {
			width: 320rpx;
			height: 320rpx;
		}

		.text {
			font-size: 28rpx;
			color: #B0B0B0;
		}
	}

	.couponList {
		margin-top: 20rpx;
	}

	.couponItem {
		position: relative;
		height: 152rpx;
		margin: 0 28rpx 32rpx;

		.itemBg {
			position: absolute;
			width: 100%;
			height: 100%;
		}

		.itemInfo {
			position: relative;
			display: flex;
			align-items: center;
			justify-content: space-between;
			position: relative;
			z-index: 1;
			padding: 34rpx 16rpx;

			.value {
				width: 176rpx;
				text-align: center;
				font-size: 60rpx;
				color: #F13933;
				font-weight: 600;
				border-right: 2rpx dashed #F6DCD3;
			}

			.infoOther {
				flex: 1;
				margin-left: 32rpx;

				.title {
					font-size: 32rpx;
					color: #F13933;
					margin-bottom: 20rpx;
				}

				.time {
					font-size: 24rpx;
					color: #999999;
				}
			}

			.use {
				width: 88rpx;
				height: 88rpx;
				margin-right: 4rpx;
			}
		}

	}
</style>